package com.coder520.foregroundservicestudy;

import android.app.IntentService;
import android.content.Intent;
import android.support.annotation.Nullable;
import android.util.Log;

/**
 * Created by huang on 2017/7/16.
 */

public class CountDownService extends IntentService {
    private static final String TAG = CountDownService.class.getSimpleName();
    int mCount = 10;
    /**
     * Creates an IntentService.  Invoked by your subclass's constructor.
     */
    public CountDownService() {
        super("countdown-thread");
    }

    @Override
    protected void onHandleIntent(@Nullable Intent intent) {
        while(mCount > 0) {
            Log.d(TAG, "coder520 current count is:" + mCount--);
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

    @Override
    public void onDestroy() {
        Log.d(TAG, "coder520 onDestroy called");
        super.onDestroy();
    }
}
